<h2>DESCRIPTION</h2>

<em>r.in.wms</em> handles all of downloading and importing raster data
from <a href="http://www.opengeospatial.org/standards/wms">OGC
WMS</a> and <a href="http://www.opengeospatial.org/standards/wmts">OGC
WMTS</a> web mapping servers. It only needs be told the
desired data to collect (bounds and resolution) via a region, the
server to get the data from, and the layer or layers to get. It
downloads the data in tiles, reprojects it, imports it, and patches it
back together.

<h2>NOTES</h2>

To understand the data you are getting it is necessary to look at the
capabilities of the WMS server. This should be available via a capabilities
request (see examples)

<p>
If possible, the EPSG code of the current location should be used with the 
<b>srs</b> option to avoid unnecessary reprojection.

<p>
When using GDAL WMS driver (<b>driver=WMS_GDAL</b>), the GDAL library
needs to be built with WMS support,
see <a href="http://gdal.org/frmt_wms.html">GDAL WMS</a> manual page
for details.

<h3>Tiled WMS</h3>

Into the parameter <b>layers</b> the name of the <i>TiledGroup</i> need to
be inserted from Tile Service file. Time variable can be specified
in <b>urlparams</b> parameter,
e.g: <tt>urlparams='time=2012-1-1'</tt>.

<h2>EXAMPLES</h2>

<h3>General Get Capabilities Request</h3>

<div class="code"><pre>
# Topographic WMS with OpenStreetMap by mundialis
r.in.wms -c url="http://ows.mundialis.de/services/service?"
r.in.wms -c url="http://ows.mundialis.de/services/service?" | grep Name

# Czech WMS
r.in.wms -c url="http://wms.cuzk.cz/wms.asp"
</pre></div>

<h3>Download raster data from WMS server (GetMap request)</h3>

<h4>Open Street Map</h4>

<div class="code"><pre>
# OSM, using WMS_GRASS driver
g.region n=90 s=-90 w=-180 e=180 res=0:10:00 -p
r.in.wms url="http://watzmann-geog.urz.uni-heidelberg.de/cached/osm" layers=osm_auto:all output=osm format=png
r.info osm
</pre></div>

<div class="code"><pre>
# OSM Overlay WMS (can be used as an overlay for other maps)
r.in.wms url="http://ows.mundialis.de/services/service?" layer=OSM-Overlay-WMS output=osm_overlay format=png

# TOPO-OSM-WMS
r.in.wms url="http://ows.mundialis.de/services/service?" layer=TOPO-OSM-WMS output=topo_osm format=png
r.info topo_osm

# TOPO-WMS
r.in.wms url="http://ows.mundialis.de/services/service?" layer=TOPO-WMS output=topo format=png
r.info topo
</pre></div>
<p>
More OSM WMS servers can be found online, e.g. on the OSM wiki in a
<a href="http://wiki.openstreetmap.org/wiki/WMS#Public_WMS_Servers">OSM WMS Servers list</a>
and on the <a href="http://wiki.openstreetmap.org/wiki/OSM-WMS-EUROPE">OSM-WMS-EUROPE</a> page.

<h4>Countries and coastlines</h4>

<div class="code"><pre>
# using WMS_GRASS driver
r.in.wms url="http://www2.demis.nl/WMS/wms.asp" layers=Countries,Borders,Coastline output=countries srs=4326 format=png 
r.info countries
</pre></div>

<h4>Sentinel-2 satellite cloud free global coverage</h4>

<div class="code"><pre>
# North Carolina sample data
g.region raster=elevation -p
# using WMS_GRASS driver
r.in.wms url="https://tiles.maps.eox.at/wms?" layers=s2cloudless output=sentinel2 format=png
r.info sentinel2
</pre></div>

<div align="center" style="margin: 10px">
<a href="r_in_wms_sentinel2.jpg"><img src="r_in_wms_sentinel2.jpg" width="600px" height="531px"></a><br>
<i>Figure: Raleigh (NC, USA) seen by Sentinel-2 (10m resolution; image courtesy: EOX)</i>
</div>

<h4>OGC WMTS Example</h4>

<div class="code"><pre>
# using WMTS_GRASS driver
r.in.wms url="http://gpp3-wxs.ign.fr/yourAPIkey/geoportail/wmts" layers=ORTHOIMAGERY.ORTHOPHOTOS \
         output=orthophoto srs=3857 format=jpeg driver=WMTS_GRASS style=normal password="*" username="*"
r.info orthophoto
</pre></div>

Note: username, password and API key can be obtained from <a href="http://api.ign.fr/">IGN API</a> website

<h4>Data covering the Czech Republic</h4>

<div class="code"><pre>
# using WMS_GRASS driver
r.in.wms url="http://wms.cuzk.cz/wms.asp" layers=prehledka_kraju-linie srs=4326 output=kn format=png
</pre></div>

<div class="code"><pre>
# using WMTS_GRASS driver
r.in.wms url="http://geoportal.cuzk.cz/WMTS_ORTOFOTO/WMTService.aspx" layers=orto output=orthophoto \
         srs=3857 format=jpeg driver=WMTS_GRASS style=default
r.info orthophoto
</pre></div>

Note: data are provided by
<a href="https://cuzk.cz/en">Czech office for surveying, mapping and cadastre</a>.


<h4>Satellite data covering Europe</h4>

Copernicus Core003 View Services - Optical VHR2 coverage over EU 2011-2013 (provided by JRC;
usage is restricted to non-commercial activities):

<div class="code"><pre>
# get WMS layer list
r.in.wms -c url="http://cidportal.jrc.ec.europa.eu/copernicus/services/ows/wms/public/core003?"
r.in.wms -c url="http://cidportal.jrc.ec.europa.eu/copernicus/services/ows/wms/public/core003?" | grep Name

# spatial subset of Europe
# enlarging maxcols and maxrows in order to minimize impact of copyright notice in map
g.region n=56 s=47 w=5 e=16 res=0:00:10 -pa
# using WMS_GRASS driver
r.in.wms url="http://cidportal.jrc.ec.europa.eu/copernicus/services/ows/wms/public/core003?" \
         layer="OI.Mosaic.NaturalColor.Feathering" output="jrc_copernicus_core003_mosaik" \
         maxcols=3400 maxrows=3400
r.info jrc_copernicus_core003_mosaik

# Alternatively, using WMS_GDAL driver with BIGTIFF and compression enabled
r.in.wms url="http://cidportal.jrc.ec.europa.eu/copernicus/services/ows/wms/public/core003?" \
         layer="OI.Mosaic.NaturalColor.Feathering" output="jrc_copernicus_core003_mosaik2" \
         maxcols=3400 maxrows=3400 driver=WMS_GDAL gdal_createopt="BIGTIFF=YES,COMPRESS=DEFLATE"
r.info jrc_copernicus_core003_mosaik2

</pre></div>


<h2>REQUIREMENTS</h2>

<em>r.in.wms</em> requires the <a href="https://gdal.org/gdalwarp.html">gdalwarp</a>
utility from the GDAL/OGR library.

<h2>REFERENCES</h2>

<ul>
  <li><a href="http://www.opengeospatial.org/standards/wms">OGC WMS</a></li>
  <li><a href="http://www.opengeospatial.org/standards/wmts">OGC WMTS</a></li>
</ul>

<h2>SEE ALSO</h2>

<em>
  <a href="r.in.gdal.html">r.in.gdal</a>,
  <a href="r.patch.html">r.patch</a>,
  <a href="r.colors.html">r.colors</a>,
  <a href="r.composite.html">r.composite</a>,
  <a href="v.in.wfs.html">v.in.wfs</a>
</em>

<p>
See also
<a href="https://grasswiki.osgeo.org/wiki/WxGUI/Video_tutorials#Add_web_service_layer">WMS support in wxGUI</a>.

<h2>AUTHOR</h2>

Stepan Turek, Czech Technical University in Prague, Czech Republic<br>
(bachelor's final project 2012, mentor: Martin Landa)

<!--
<p>
<i>Last changed: $Date$</i>
-->
